package com.ruoyi.business.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.business.vo.TRegisterSignSmsVo;
import com.ruoyi.business.service.ITRegisterSignSmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.page.TableDataInfo;

import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;

/**
 * 科主任签字发送短信Controller
 *
 * @author Tellsea
 * @date 2025-04-07
 */
@Api(tags = "科主任签字发送短信Controller")
@RestController
@RequestMapping("/business/registerSignSms")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class TRegisterSignSmsController extends BaseController {

    private final ITRegisterSignSmsService tRegisterSignSmsService;

    @ApiOperation("查询科主任签字发送短信列表")
    @PreAuthorize("@ss.hasPermi('business:registerSignSms:list')")
    @GetMapping("/list")
    public TableDataInfo<TRegisterSignSmsVo> list(TRegisterSignSmsVo entity) {
        return tRegisterSignSmsService.queryList(entity);
    }

    @ApiOperation("查询科主任签字发送短信所有列表")
    @GetMapping("/listAll")
    public AjaxResult listAll(TRegisterSignSmsVo entity) {
        return AjaxResult.success("查询成功", tRegisterSignSmsService.queryAll(entity));
    }

    @ApiOperation("导出科主任签字发送短信列表")
    @PreAuthorize("@ss.hasPermi('business:registerSignSms:export')")
    @Log(title = "科主任签字发送短信", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TRegisterSignSmsVo entity) {
        List<TRegisterSignSmsVo> list = tRegisterSignSmsService.queryAll(entity);
        ExcelUtil<TRegisterSignSmsVo> util = new ExcelUtil<>(TRegisterSignSmsVo.class);
        util.exportExcel(response, list, "科主任签字发送短信数据");
    }

    @ApiOperation("获取科主任签字发送短信详细信息")
    @PreAuthorize("@ss.hasPermi('business:registerSignSms:query')")
    @GetMapping(value = "/getInfo/{registerId}")
    public AjaxResult getInfo(@PathVariable("registerId") Long registerId) {
        return AjaxResult.success("查询成功", tRegisterSignSmsService.queryById(registerId));
    }

    @ApiOperation("新增科主任签字发送短信")
    @PreAuthorize("@ss.hasPermi('business:registerSignSms:add')")
    @Log(title = "科主任签字发送短信", businessType = BusinessType.INSERT)
    @PostMapping("add")
    public AjaxResult add(@RequestBody TRegisterSignSmsVo entity) {
        return toAjax(tRegisterSignSmsService.save(entity));
    }

    @ApiOperation("修改科主任签字发送短信")
    @PreAuthorize("@ss.hasPermi('business:registerSignSms:edit')")
    @Log(title = "科主任签字发送短信", businessType = BusinessType.UPDATE)
    @PostMapping("edit")
    public AjaxResult edit(@RequestBody TRegisterSignSmsVo entity) {
        return toAjax(tRegisterSignSmsService.updateById(entity));
    }

    @ApiOperation("删除科主任签字发送短信")
    @PreAuthorize("@ss.hasPermi('business:registerSignSms:remove')")
    @Log(title = "科主任签字发送短信", businessType = BusinessType.DELETE)
	@GetMapping("/remove/{registerIds}")
    public AjaxResult remove(@PathVariable Long[] registerIds) {
        return toAjax(tRegisterSignSmsService.removeByIds(Arrays.asList(registerIds)) ? 1 : 0);
    }
}
